﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using MySql.Data.MySqlClient;
using System.Data.SqlClient;

namespace DMU.Gui.GuiPro
{
    public partial class frmChuyenDoi : DevExpress.XtraEditors.XtraForm
    {
        private GuiPro.frmChuyenDoiThongTin frmCD;
        public frmChuyenDoi(GuiPro.frmChuyenDoiThongTin frmCD )
        {
            this.frmCD = frmCD;
            InitializeComponent();
        }

        Service sv = new Service();
        help hp = new help();

        private void btnHoanTat_Click(object sender, EventArgs e)
        {
            if (lkpPhong.EditValue == null)
            {
                lkpPhong.Focus(); return;
            }

            SqlParameter[] pr = new SqlParameter[4];
            pr[0]=new SqlParameter("MaTKB0",txtMaTKB.Text);
            pr[1]=new SqlParameter("Ngay0",dteNgayMoi.DateTime);
            pr[2]=new SqlParameter("MaPhong0",lkpPhong.EditValue.ToString());
            pr[3]=new SqlParameter("TietBD0",txtTietBDMoi.Text);
            //if(sv.executeNonqueryStore("dmu_chuyenDoiThongTin",pr))
            //{
            //    int row = frmCD.gridView3.FocusedRowHandle;
            //    frmCD.gridView3.SetRowCellValue(row, "Ngay", dteNgayMoi.DateTime);
            //    frmCD.gridView3.SetRowCellValue(row, "MaPhong", lkpPhong.EditValue.ToString());
            //    frmCD.gridView3.SetRowCellValue(row, "TietBD", txtTietBDMoi.Text);
            //    hp.showMes("Chuyển đổi thành công !",-1);
            //    this.Close();
            //}
        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void lkpPhong_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (lkpPhong.Text.Trim() != "")
                {
                    DataTable dt = sv.getDatatable("dmu_proPublicFindPhong", new SqlParameter("name", lkpPhong.Text + "%"));
                    
                    lkpPhong.Properties.DataSource = dt;
                    lkpPhong.Properties.ValueMember = "MaPhong";
                    lkpPhong.Properties.DisplayMember = "TenPhong";
                }

            }
        }

        private void frmChuyenDoi_Load(object sender, EventArgs e)
        {

        }
    }
}